package com.stu.dao.impl;

import com.stu.dao.RowMapper;
import com.stu.entity.Emp;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;

/**
 * 接收Emp对象
 * @author zy
 * @date 2025/3/4 16:39
 */
public class EmpRowMapper implements RowMapper<Emp> {
    @Override
    public Emp mapper(ResultSet rs) {
        Emp emp = null;

        try {
            int empno = rs.getInt(1);
            String ename = rs.getString(2);
            String job = rs.getString(3);
            int mgr = rs.getInt(4);
            LocalDateTime hiredate = rs.getTimestamp(5).toLocalDateTime();
            float salary = rs.getFloat(6);
            float comm = rs.getFloat(7);
            int deptno = rs.getInt(8);

            emp = new Emp(empno,ename,job,mgr,hiredate,salary,comm,deptno);

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

        return emp;
    }
}
